

package com.maoshi.shop.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maoshi.shop.bean.model.User;
import com.maoshi.shop.bean.model.UserExtension;
import com.maoshi.shop.common.util.PageParam;
import com.maoshi.shop.dao.UserExtensionMapper;
import com.maoshi.shop.dao.UserMapper;
import com.maoshi.shop.service.UserExtensionService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户扩展信息
 *
 * @author LGH
 * @date 2020-02-26 16:03:14
 */
@Service
@AllArgsConstructor
public class UserExtensionServiceImpl extends ServiceImpl<UserExtensionMapper, UserExtension> implements UserExtensionService {

    private final UserExtensionMapper userExtensionMapper;
    private final UserMapper userMapper;

    @Override
    public Page<UserExtension> getPage(PageParam<UserExtension> page, UserExtension userExtension) {
        return userExtensionMapper.getPage(page,userExtension);
    }

    @Override
    public void setUserLevelBylevelId(Integer level) {
        userExtensionMapper.setUserLevelBylevelId(level);
    }

    @Override
    public void setMaxUserLevelByLevelId(Integer level, Integer minNeedGrowth, Integer maxNeedGrowth) {
        userExtensionMapper.serMaxUserLavelByLevelId(level,minNeedGrowth,maxNeedGrowth);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateMemberByTime(List<User> userList, List<UserExtension> userExtensions) {
        userMapper.updateBatchById(userList);

        updateBatchById(userExtensions);
    }
}
